package org.monster.context.core.processor;

import org.monster.context.core.Constants;
import org.monster.context.core.parameter.HttpResponse;
import org.monster.context.core.parser.JspParser;
import org.monster.context.core.request.HttpRequest;

import java.io.File;

/**
 * 处理 jsp
 *
 * @author Monster
 */
public class ProcessJsp extends ProcessResource implements Process {

    /**
     * jsp解析器
     */
    private final JspParser parser;

    /**
     * 构造方法
     *
     * @param parser 解析器
     */
    public ProcessJsp(JspParser parser) {
        super();
        this.parser = parser;
    }

    /**
     * 处理
     *
     * @param request  请求
     * @param response 响应
     */
    @Override
    public boolean process(HttpRequest request, HttpResponse response) {
        parser.parseJsp(new File(Constants.APPS_PATH, request.getRequestURI()));
        return true;
    }
}
